//
//  MyGoodsOrderCell.m
//  MIT-AffordSuperMarket
//
//  Created by apple on 16/3/3.
//  Copyright © 2016年 河南大实惠电子商务有限公司. All rights reserved.
//

#import "MyGoodsOrderCell.h"

#define KLeftSpacing 15
#define KRightSpacing 15
#define KCellHigtle 185
#define KTopSpacing 10

#import "Global.h"
#import "UIImage+ColorToImage.h"
#import "UIColor+Hex.h"
#import "MyOrderCell.h"
#import "NSString+Conversion.h"
//model
#import "MyOrderModel.h"
//vendor
#import "UIImageView+AFNetworking.h"
#import "ManagerGlobeUntil.h"
#import "XiaoQuAndStoreInfoModel.h"


@interface MyGoodsOrderCell()
//订单状态
@property (nonatomic,strong)UILabel *orderState;
//商品logo
@property (nonatomic,strong)UIImageView *goodsImage;
//多个商品
@property (nonatomic,strong)UIImageView *goodsImageone;
@property (nonatomic,strong)UIImageView *goodsImagetwo;
@property (nonatomic,strong)UIImageView *goodsImagethree;
//商品名称
@property (nonatomic,strong)UILabel *goodsName;
//实际付款价格
@property (nonatomic,strong)UILabel *goodsMoney;

//一件商品的订单
@property (nonatomic,strong)UIView *oneView;

//更多商品的订单
@property (nonatomic,strong)UIView *moreView;

//服务订单 参数
@property(nonatomic,strong)UILabel *shopName;
@property(nonatomic,strong)UIImageView *logoImageView;

@end

@implementation MyGoodsOrderCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpSuberView];
    }
    return self;
}

#pragma mark --ButtonClick
-(void)goPayClick:(UIButton *)sender
{
    UIButton *btn =(UIButton*)sender;
    if (_delegate && [_delegate respondsToSelector:@selector(selectedFirstItemWithTag:title:)]) {
        [_delegate selectedFirstItemWithTag:btn.tag  title:btn.titleLabel.text];
    }
}
-(void)deleteOrderClick:(UIButton *)sender
{
    UIButton *btn =(UIButton*)sender;
    if (_delegate && [_delegate respondsToSelector:@selector(selectedSecondItemWithTag:title:)]) {
        [_delegate selectedSecondItemWithTag:btn.tag title:btn.titleLabel.text];
    }
}

#pragma mark -- 更新数据源
- (void)updateViewwithData:(NSDictionary*)dataDic{
    //付款价格
    NSString *totalPrice = [NSString stringWithFormat:@"实付款：￥%.2f",[[NSString stringTransformObject:[dataDic objectForKey:@"REALPAY"]] floatValue]];
    NSMutableAttributedString *totalPriceAttributedStr = [[NSMutableAttributedString alloc]initWithString:totalPrice];
    //设置：在0-3个单位长度内的内容显示成红色
    [totalPriceAttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#555555"] range:NSMakeRange(4,totalPriceAttributedStr.length-4)];
    self.goodsMoney.attributedText = totalPriceAttributedStr;
    //订单状态
    NSString *isSelf = [NSString stringTransformObject:[dataDic objectForKey:@"ISSELF"]];
    if ([isSelf isEqualToString:@"1"]) {
        self.shopName.text=kDaShiHuiStoreName;

    }else{
        XiaoQuAndStoreInfoModel *model = [[ManagerGlobeUntil sharedManager]getxiaoQuAndStoreInfo];
        self.shopName.text=model.storeName;
    }

        if ([[dataDic objectForKey:@"GOODSLIST"] count] > 1) {//一个表单包含两个商品
//            [self.contentView insertSubview:self.moreView aboveSubview:self.oneView];
            self.moreView.hidden = NO;
            self.oneView.hidden = YES;
            NSMutableArray *imageUrs = [[NSMutableArray alloc]init];
            for (NSDictionary *dic in [dataDic objectForKey:@"GOODSLIST"]) {//把图片保存起来
                NSString *imageurl = [NSString stringTransformObject:[dic objectForKey:@"THUMB"]];
                [imageUrs addObject:[NSString appendImageUrlWithServerUrl:imageurl]];
            }
            for (NSInteger i = 0; i < [imageUrs count]; i++) {
                if (i == 0) {
                    [self.goodsImageone setImageWithURL:[NSURL URLWithString:[imageUrs objectAtIndex:i]]
                                       placeholderImage:[UIImage imageNamed:@"place_image"]];
                } else if (i == 1) {
                    [self.goodsImagetwo setImageWithURL:[NSURL URLWithString:[imageUrs objectAtIndex:i]]
                                       placeholderImage:[UIImage imageNamed:@"place_image"]];
                } else if (i == 2) {
                    [self.goodsImagethree setImageWithURL:[NSURL URLWithString:[imageUrs objectAtIndex:i]]
                                         placeholderImage:[UIImage imageNamed:@"place_image"]];
                }
            }
            
        } else {//一个表单只包含1个商品
//            [self.contentView insertSubview:self.oneView aboveSubview:self.moreView];
            self.moreView.hidden = YES;
            self.oneView.hidden = NO;
            NSDictionary *dic = [[dataDic objectForKey:@"GOODSLIST"] firstObject];
            NSString *imageurl =  [NSString stringTransformObject:[dic objectForKey:@"THUMB"]];
            [self.goodsImage setImageWithURL:[NSURL URLWithString:[NSString appendImageUrlWithServerUrl:imageurl]]
                            placeholderImage:[UIImage imageNamed:@"place_image"]];
            self.goodsName.text = [NSString stringTransformObject:[dic objectForKey:@"NAME"]];
        }
        
        
        self.orderState.text = [self judgeOrderStatusWithOrderState:[NSString stringTransformObject:[dataDic objectForKey:@"ORDERSTATE"] ] PayState:[NSString stringTransformObject:[dataDic objectForKey:@"PAYSTATE"] ] DeliveState:[NSString stringTransformObject:[dataDic objectForKey:@"DELIVERSTATE"]] PayType:[NSString stringTransformObject:[dataDic objectForKey:@"PAYTYPE"]] DeliveType:[NSString stringTransformObject:[dataDic objectForKey:@"TAKETYPE"]] packState:[NSString stringTransformObject:[dataDic objectForKey:@"PACKSTATE"]] EvelState:[NSString stringTransformObject:[dataDic objectForKey:@"EVALSTATE"]]];
    
    
}
#pragma mark --根据状态设置订单页面按钮 和右上角 订单装态
- (NSString*)judgeOrderStatusWithOrderState:(NSString*)OrderState PayState:(NSString *)PayState DeliveState:(NSString *)DeliveState PayType:(NSString *)payType DeliveType:(NSString *)DeliveType packState:(NSString *)packState EvelState:(NSString *)evelState
{
    CGRect firstframe=self.goPay.frame;//第一个按钮位置
    CGRect twoframe=CGRectMake(CGRectGetMinX(self.goPay.frame)-90, CGRectGetMinY(self.goPay.frame), CGRectGetWidth(self.goPay.bounds), CGRectGetHeight(self.goPay.bounds));//第二个按钮位置
    
    if ([OrderState isEqualToString:KOrderStateNormal] )
    {//订单正常  支付状态为 未支付
        if ([payType isEqualToString:KOrderPayTypeIsPayPal] && [DeliveType isEqualToString:KOrderDeliverTypeIsDelivery])//在线付款+送货上门
        {
            if ([PayState isEqualToString:KOrderPayStateIsNo]) {
                [self.goPay setTitle:@"去支付" forState:UIControlStateNormal];
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];

                self.deleteOrder.hidden=YES;
                return @"等待付款";
            }else if([PayState isEqualToString:KOrderPayStateIsYes]&&[DeliveState isEqualToString:KOrderDeliverStateIsNo])//订单正常  支付状态为 已支付
            {
                if ([packState isEqualToString:KOrderPackState1]) {
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"付款成功";
                }else if([packState isEqualToString:KOrderPackState2]){
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"打包中";
                }
                else if([packState isEqualToString:KOrderPackState3]){
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"打包中";
                }
                else if([packState isEqualToString:KOrderPackState4]){
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"待配送";
                }
            }else if([DeliveState isEqualToString:KOrderDeliverStateIsYes]){//订单正常  收货状态为 已发货
                self.deleteOrder.hidden=NO;
                self.deleteOrder.frame =twoframe;
                [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                [self.deleteOrder setTitle:@"确认收货" forState:UIControlStateNormal];
                [self.deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
                [self.deleteOrder setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];
                return @"配送中";
;
            }

        }else if([payType isEqualToString:KOrderPayTypeIsPayPal]&& [DeliveType isEqualToString:KOrderDeliverTypeIsSelfUp]){//自取 +在线付款
            
            if([PayState isEqualToString:KOrderPayStateIsNo]){
                [self.goPay setTitle:@"去支付" forState:UIControlStateNormal];
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];
                self.deleteOrder.hidden=YES;
                return @"等待付款";
                
            }else if([PayState isEqualToString:KOrderPayStateIsYes])
            {
                if ([packState isEqualToString:KOrderPackState1]) {
                    self.deleteOrder.hidden=YES;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"付款成功";
                }else if([packState isEqualToString:KOrderPackState2]){
                    self.deleteOrder.hidden=YES;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"打包中";
                }
                else if([packState isEqualToString:KOrderPackState3]){
                    self.deleteOrder.hidden=YES;
                   [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"打包中";
                }
                else if([packState isEqualToString:KOrderPackState4]){
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [self.deleteOrder setTitle:@"确认取货" forState:UIControlStateNormal];
                    [self.deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
                    [self.deleteOrder setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];

                    return @"待取货";
                }
            }

        }else if([payType isEqualToString:KOrderPayTypeIsCOD]&&[DeliveType isEqualToString:KOrderDeliverTypeIsDelivery]) //货到付款 + 送货上门
        {
            if([DeliveState isEqualToString:KOrderDeliverStateIsNo]){
                if ([packState isEqualToString:KOrderPackState1]) {
                    
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"处理中";
                }else if([packState isEqualToString:KOrderPackState2]){
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"打包中";
                }
                else if([packState isEqualToString:KOrderPackState3]){
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"打包中";
                }
                else if([packState isEqualToString:KOrderPackState4]){
                    self.deleteOrder.hidden=NO;
                    self.deleteOrder.frame =twoframe;
                    [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                    [self.deleteOrder setTitle:@"催单" forState:UIControlStateNormal];
                    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                    return @"待配送";
                }
            }else if ([DeliveState isEqualToString:KOrderDeliverStateIsYes])//2
            {
                self.deleteOrder.hidden=NO;
                self.deleteOrder.frame =twoframe;
                [self.deleteOrder setTitle:@"确认收货" forState:UIControlStateNormal];
                [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                [self.deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
                [self.deleteOrder setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];

                return @"配送中";
            }
            
        }else if([payType isEqualToString:KOrderPayTypeIsCOD]&&[DeliveType isEqualToString:KOrderDeliverTypeIsSelfUp]) //货到付款 + 自取
        {
            if ([packState isEqualToString:KOrderPackState1]) {
                [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                self.deleteOrder.hidden=YES;
                return @"处理中";
            }else if([packState isEqualToString:KOrderPackState2]){
                [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                self.deleteOrder.hidden=YES;
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                return @"打包中";
            }
            else if([packState isEqualToString:KOrderPackState3]){
                [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                self.deleteOrder.hidden=YES;
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                return @"打包中";
            }
            else if([packState isEqualToString:KOrderPackState4]){
                [self.goPay setTitle:@"订单跟踪" forState:UIControlStateNormal];
                self.deleteOrder.hidden=NO;
                self.deleteOrder.frame =twoframe;
                [self.deleteOrder setTitle:@"确认取货" forState:UIControlStateNormal];
                [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
                [_goPay setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
                [self.deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
                [self.deleteOrder setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];

                return @"待取货";
            }
        }
    }  else if([OrderState isEqualToString:KOrderStateFinish])//订单状态为已完成
    {
        if ([evelState isEqualToString:KOrderEvalStateIsNo]) {
            [self.goPay setTitle:@"去评价" forState:UIControlStateNormal];
            [self.goPay.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
            [self.goPay setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];
            self.deleteOrder.hidden=YES;
            return @"交易完成";
        }else if ([evelState isEqualToString:KOrderEvalStateIsYse]){
            self.deleteOrder.hidden=NO;
            [self.deleteOrder setTitle:@"删除订单" forState:UIControlStateNormal];
            self.deleteOrder.frame=firstframe;
            [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
            [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
            return @"交易完成";
        }
        
    }else if ([OrderState isEqualToString:KOrderStateCancel])//订单状态为已取消
    {
        self.deleteOrder.hidden=NO;
        [self.deleteOrder setTitle:@"删除订单" forState:UIControlStateNormal];
        self.deleteOrder.frame=firstframe;
        [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
        [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
        return @"已取消";
    } else if ([OrderState isEqualToString:KOrderStateBeOverdue])//订单状态为已过期
    {
        self.deleteOrder.hidden=NO;
        [self.deleteOrder setTitle:@"删除订单" forState:UIControlStateNormal];
        self.deleteOrder.frame=firstframe;
        [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
        [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
        return @"已过期";
    }
    return @"";
}
#pragma mark -初始化控件
-(void)setUpSuberView
{
    _views = [[UIView alloc]initWithFrame:CGRectMake(0, 0, VIEW_WIDTH, HightScalar(12))];
        _views.backgroundColor = [UIColor colorWithHexString:@"#efefef"];
//    [_views.layer setBorderWidth:0.5];
//    [_views.layer setBorderColor:[UIColor colorWithHexString:@"#dddddd"].CGColor];
    [self.contentView addSubview:_views];
    //cell 边框
//    [self.layer setBorderWidth:0.5];
//    [self.layer setBorderColor:[UIColor colorWithHexString:@"#dddddd"].CGColor];
    //    //标签图片
    //    _logoImageView=[[UIImageView alloc]initWithFrame:CGRectMake(KLeftSpacing,KTopSpacing,65, 20)];
    //    _logoImageView.image=[UIImage imageNamed:@"img_dashihui_logo"];
    //    [self addSubview:_logoImageView];
    //    _logoImageView.hidden=YES;
    _shopName =[[UILabel alloc]initWithFrame:CGRectMake(KLeftSpacing,CGRectGetMaxY(_views.frame),VIEW_WIDTH-80-30, HightScalar(50))];
    _shopName.font=[UIFont systemFontOfSize:FontSize(17)];
    _shopName.textColor=[UIColor colorWithHexString:@"#555555"];
    [self.contentView addSubview:_shopName];
    //订单状态
    _orderState =[[UILabel alloc]initWithFrame:CGRectMake(VIEW_WIDTH-VIEW_WIDTH/2-15
                                                          , CGRectGetMinY(_shopName.frame)
                                                          , VIEW_WIDTH/2
                                                          , CGRectGetHeight(_shopName.bounds))];
    _orderState.font=[UIFont systemFontOfSize:FontSize(16)];
    _orderState.textAlignment =NSTextAlignmentRight;
    _orderState.textColor=[UIColor colorWithHexString:@"#d80000"];
    [self.contentView addSubview:_orderState];
    //一个物品时的view
    _oneView =[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_shopName.frame)+1
                                                      , VIEW_WIDTH, HightScalar(108))];
    _oneView.backgroundColor=[UIColor whiteColor];
    [self addSubview:_oneView];
    //商品图片
    _goodsImage=[[UIImageView alloc]initWithFrame:CGRectMake(KLeftSpacing, (CGRectGetHeight(self.oneView.bounds)-HightScalar(75))/2, HightScalar(75), HightScalar(75))];
    _goodsImage.contentMode= UIViewContentModeScaleAspectFit;
    [self.oneView addSubview:_goodsImage];
    
    //商品名称
    _goodsName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.goodsImage.frame)+10
                                                        , (CGRectGetHeight(self.oneView.bounds)-HightScalar(50))/2
                                                        , VIEW_WIDTH-CGRectGetWidth(self.goodsImage.bounds)-KLeftSpacing-KRightSpacing-10
                                                        , HightScalar(50))];
    _goodsName.font =[UIFont systemFontOfSize:FontSize(16)];
    _goodsName.numberOfLines=0;
    _goodsName.textColor=[UIColor colorWithHexString:@"#5a5a5a"];
    [self.oneView addSubview:_goodsName];
    
    
    //多件商品
    _moreView =[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_shopName.frame)+1, VIEW_WIDTH, CGRectGetHeight(_oneView.bounds))];
    _moreView.backgroundColor=[UIColor whiteColor];
    [self addSubview:_moreView];
    //商品图片
    _goodsImageone=[[UIImageView alloc]initWithFrame:CGRectMake(KLeftSpacing, (CGRectGetHeight(self.moreView.bounds)-HightScalar(75))/2, CGRectGetWidth(self.goodsImage.bounds), CGRectGetHeight(self.goodsImage.bounds))];
    [self.moreView addSubview:_goodsImageone];
    _goodsImageone.contentMode= UIViewContentModeScaleAspectFit;
    
    _goodsImagetwo=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.goodsImageone.frame)+10, CGRectGetMinY(self.goodsImageone.frame),CGRectGetWidth(self.goodsImage.bounds), CGRectGetHeight(self.goodsImage.bounds))];
    [self.moreView addSubview:_goodsImagetwo];
    _goodsImagetwo.contentMode= UIViewContentModeScaleAspectFit;
    
    _goodsImagethree=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.goodsImagetwo.frame)+10, CGRectGetMinY(self.goodsImagetwo.frame), CGRectGetWidth(self.goodsImage.bounds), CGRectGetHeight(self.goodsImage.bounds))];
    [self.moreView addSubview:_goodsImagethree];
    _goodsImagethree.contentMode= UIViewContentModeScaleAspectFit;
    
    
    
    //服务订单中间部分cell
    
    //灰色分割线
    UILabel *labelone=[[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_shopName.frame), VIEW_WIDTH, 1)];
    labelone.backgroundColor=[UIColor colorWithHexString:@"#e3e3e3"];
    [self.contentView addSubview:labelone];
    //灰色分割线
    UILabel *labeltwo=[[UILabel alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(_oneView.frame), VIEW_WIDTH, 1)];
    labeltwo.backgroundColor=[UIColor colorWithHexString:@"#e3e3e3"];
    [self.contentView addSubview:labeltwo];
    
    //实际付款：
    _goodsMoney=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(_shopName.frame), CGRectGetMaxY(labeltwo.frame), VIEW_WIDTH/2, HightScalar(58))];
    _goodsMoney.textColor=[UIColor colorWithHexString:@"#555555"];
    _goodsMoney.font=[UIFont systemFontOfSize:FontSize(16)];
    [self.contentView addSubview:_goodsMoney];
    
    
    //去付款
    _goPay=[UIButton buttonWithType:UIButtonTypeCustom];
    _goPay.frame=CGRectMake(VIEW_WIDTH-90, CGRectGetMinY(_goodsMoney.frame)+(CGRectGetHeight(self.goodsMoney.frame)-HightScalar(37))/2, 75, HightScalar(37));
    UIImage *goPayBackgroundImage = [UIImage createImageWithColor:[UIColor whiteColor]
                                                            frame:CGRectMake(0, 0, CGRectGetWidth(_goPay.bounds), CGRectGetHeight(_goPay.bounds))];
    [_goPay setBackgroundImage:goPayBackgroundImage forState:UIControlStateNormal];
    [_goPay setTitle:@"去支付" forState:UIControlStateNormal];
    [_goPay.layer setBorderWidth:0.5];
    [_goPay.layer setBorderColor:[UIColor colorWithHexString:@"#c52720"].CGColor];
    [_goPay setTitleColor:[UIColor colorWithHexString:@"#c52720"] forState:UIControlStateNormal];
//    _goPay.titleLabel.textColor=[UIColor whiteColor];
    _goPay.titleLabel.font=[UIFont systemFontOfSize:FontSize(15)];
    [_goPay addTarget:self action:@selector(goPayClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [_goPay.layer setMasksToBounds:YES];
    [_goPay.layer setCornerRadius:4.0];
    [self.contentView addSubview:_goPay];
    
    //删除订单
    _deleteOrder=[UIButton buttonWithType:UIButtonTypeCustom];
    _deleteOrder.frame=CGRectMake(CGRectGetMinX(self.goPay.frame)-90, CGRectGetMinY(self.goPay.frame), CGRectGetWidth(self.goPay.bounds), CGRectGetHeight(self.goPay.bounds));
    [_deleteOrder.layer setBorderWidth:0.5];
    [_deleteOrder.layer setBorderColor:[UIColor colorWithHexString:@"#555555"].CGColor];
    [_deleteOrder setTitle:@"删除订单" forState:UIControlStateNormal];
    [_deleteOrder setTitleColor:[UIColor colorWithHexString:@"#555555"] forState:UIControlStateNormal];
    UIImage *deleteOrderBackgroundImage = [UIImage createImageWithColor:[UIColor whiteColor]
                                                                  frame:CGRectMake(0, 0, CGRectGetWidth(_deleteOrder.bounds), CGRectGetHeight(_deleteOrder.bounds))];
    [_deleteOrder setBackgroundImage:deleteOrderBackgroundImage forState:UIControlStateNormal];
    
    [_deleteOrder addTarget:self action:@selector(deleteOrderClick:) forControlEvents:UIControlEventTouchUpInside];
    _deleteOrder.titleLabel.font=[UIFont systemFontOfSize:FontSize(15)];
    [_deleteOrder.layer setMasksToBounds:YES];
    [_deleteOrder.layer setCornerRadius:4.0];
    [self.contentView addSubview:_deleteOrder];
    
    
}


@end

